home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 22
/
Amiga Format AFCD22 (Jan 1998, Issue 106).iso
/
-in_the_mag-
/
assembler
/
test.s
< prev
next >
Wrap
Text File
|
1997-11-21
|
3KB
|
130 lines
* --------------------------------------------------------------------
* test.s
* --------------------------------------------------------------------
; this initial material would normaly be provided as a separate header
; file - it provides the _LVO values for the functions being used
; together with the macros used by the program...
_AbsExecBase EQU 4
_LVOOpenLibrary EQU -552
_LVOCloseLibrary EQU -414
_LVOOutput EQU -60
_LVOWrite EQU -48
NULL EQU 0
LF EQU 10
XDEF _main
LINKLIB MACRO
IFGT NARG-2
FAIL ;too many arguments
ENDC
move.l a6,-(sp)
move.l \2,a6
jsr \1(a6)
move.l (sp)+,a6
ENDM
CALLSYS MACRO
LINKLIB _LVO\1,\2
ENDM
WRITEDOS MACRO
movem.l d1-d3,-(sp) preserve registers d1-d3
move.l \2,d1 DOS output file handle
move.l #\1,d2 start of message
move.l #\1_SIZEOF,d3 size of message
CALLSYS Write,_DOSBase DOS call to write message
movem.l (sp)+,d1-d3 restore registers d1-d3
ENDM
* --------------------------------------------------------------------
; The following stuff is the program itself...
_main move.l _AbsExecBase,_SysBase set up SysBase variable
lea dos_name,a1 library name start in a1
moveq #0,d0 any version will do
CALLSYS OpenLibrary,_SysBase macro (see article for details)
move.l d0,_DOSBase store returned value
beq EXIT quit if NULL
; if we reach here the DOS library is open and functions can be used...
CALLSYS Output,_DOSBase get default output handle
move.l d0,_stdout store output handle
beq CLOSELIB
; have obtained valid output handle so message can be written...
WRITEDOS message,_stdout get DOS to write message
; all done so now we can close DOS library...
CLOSELIB move.l _DOSBase,a1 base needed in a1
CALLSYS CloseLibrary,_SysBase
; and terminate the program...
EXIT clr.l d0
rts logical end of program
* --------------------------------------------------------------------
; these are all the variables and static data...
_stdout ds.l 1
_SysBase ds.l 1
_DOSBase ds.l 1
dos_name dc.b 'dos.library',NULL
message dc.b 'Amiga Format Rules OK!',LF
message_SIZEOF EQU *-message
END
* --------------------------------------------------------------------